configureMenuItem

open fun configureMenuItem(@NonNull item: @NonNull MenuItem, @NonNull shareIntent: @NonNull ShareCompat.IntentBuilder)(source)

Deprecated

Use the system sharesheet. See https://developer.android.com/training/sharing/send

Configure a MenuItem to act as a sharing action.

This method will configure a ShareActionProvider to provide a more robust UI for selecting the target of the share. History will be tracked for each calling activity in a file named with the prefix ".sharecompat_" in the application's private data directory. If the application wishes to set this MenuItem to show as an action in the Action Bar it should use setShowAsAction to request that behavior in addition to calling this method.

During the calling activity's lifecycle, if data within the share intent must change the app should change that state in one of several ways:

  • Call invalidateOptionsMenu. If the app uses the Action Bar its menu will be recreated and rebuilt. If not, the activity will receive a call to onPrepareOptionsMenu the next time the user presses the menu key to open the options menu panel. The activity can then call configureMenuItem again with a new or altered IntentBuilder to reconfigure the share menu item.
  • Keep a reference to the MenuItem object for the share item once it has been created and call configureMenuItem to update the associated sharing intent as needed.

Parameters

item

MenuItem to configure for sharing

shareIntent

IntentBuilder with data about the content to share


open fun configureMenuItem(@NonNull menu: @NonNull Menu, @IdRes menuItemId: Int, @NonNull shareIntent: @NonNull ShareCompat.IntentBuilder)(source)

Deprecated

Use the system sharesheet. See https://developer.android.com/training/sharing/send

Configure a menu item to act as a sharing action.

Parameters

menu

Menu containing the item to use for sharing

menuItemId

ID of the share item within menu

shareIntent

IntentBuilder with data about the content to share

See also